package com.example.demo.controller;

import com.example.demo.controller.bean.Result;
import com.example.demo.mapper.entity.*;
import com.example.demo.service.SelectorService;
import com.example.demo.utils.TreeBo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("selectorManage")
@Api(value = "选择器管理接口", tags = {"选择器管理接口"})
@RestController
@Slf4j
public class SelectorController {
    @Autowired
    private SelectorService service;
    @GetMapping("getItemList")
    @ApiOperation(value = "打卡图片要求选择器接口")
    @ResponseBody
    public Result<List<Item>> getItemList(){
        List<Item> list = service.getItemList();
        return Result.ok(list);
    }
    @GetMapping("getAttributeList")
    @ApiOperation(value = "屬性选择器接口")
    @ResponseBody
    public Result<List<Attribute>> getAttributeList(){
        List<Attribute> list = service.getAttributeList();
        return Result.ok(list);
    }
    @ApiOperation("服裝选择器接口")
    @RequestMapping(value = "getClothingList", method = RequestMethod.GET)
    public Result<List<TreeBo>> getClothingList() {
        List<TreeBo> list = service.selectClothingTree();
        return Result.ok(list);
    }
    @ApiOperation("優惠券選擇接口")
    @RequestMapping(value = "getCouponsList", method = RequestMethod.GET)
    public Result<List<TreeBo>> getCouponsList() {
        List<TreeBo> list = service.selectCouponsTree();
        return Result.ok(list);
    }

    @ApiOperation("徽章顯示接口")
    @RequestMapping(value = "getBadgeList", method = RequestMethod.GET)
    public Result<List<TreeBo>> getBadgeList() {
        List<TreeBo> list = service.selectBadgeTree();
        return Result.ok(list);
    }

    @ApiOperation("获取學院列表")
    @RequestMapping("getCollegeList")
    public Result<Object> getCollegeList() {
        List<College> list = service.getCollegeList();
        return Result.ok(list);
    }

    @ApiOperation("获取专业列表")
    @RequestMapping("getMajorList/{collegeId}")
    public Result<Object> getMajorList(@PathVariable("collegeId") int collegeId) {
        List<Major> list = service.getMajorList(collegeId);
        return Result.ok(list);
    }

    @ApiOperation("获取班級列表")
    @RequestMapping("getClassList/{majorId}")
    public Result<Object> getClassList(@PathVariable("majorId") int majorId) {
        List<Clazz> list = service.getClazzList(majorId);
        return Result.ok(list);
    }
}
